package com.lesson12.dynamic.ex;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/10/2 13:23
 */
public class StarHandler implements InvocationHandler
{
    private Star star;

    public StarHandler(Star star)
    {
        this.star = star;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
    {
        Object obj = null;
        System.out.println("真实角色调用之前的处理.....");
        if(method.getName().equals("sing")){
            obj = method.invoke(star, args);
        }
        System.out.println("真实角色调用之后的处理.....");
        return obj;
    }
}
